from operator import itemgetter
import numpy as np

types =  ('bool8 bool_ byte cdouble cfloat character clongdouble '
          'clongfloat complex128 complex192 complex64 complex_ complexfloating '
          'csingle double float32 float64 float96 float_ floating '
          'inexact int0 int16 int32 int64 int8 int_ intc integer intp '
          'longcomplex longdouble longfloat longlong number object0 object_ short '
          'signedinteger single singlecomplex str_ string0 string_ ubyte ufunc '
          'uint uint0 uint16 uint32 uint64 uint8 uintc uintp ulonglong unicode0 '
          'unicode_ unsignedinteger ushort').split()

temp = []
for t in types:
    exec 'dtype = np.%s' % t
    #print '%20s' % ('np.' + t),
    a = np.array([], dtype=dtype)
    temp.append(('np.'+t, a.dtype.char, a.dtype.name, a.dtype.descr[0][1]))
    #print '%s %10s %5s' % (a.dtype.char, a.dtype.name, a.dtype.descr[0][1])

temp.sort(key=itemgetter(1))

for t in temp:
    print '%20s %s %12s %5s' % t

# number of different types (maybe?)
chars = set(t[1] for t in temp)
print len(chars), 'types:', list(chars) 

# void 'V' is missing, because it won't take that type when creating
# an array from empty list. So all the chars just listed + 'V' makes
# 21 types.  uintp and intp (pointers to an integers that can hold an
# address) are sort of two more types, so 23 types?
